home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 2: CDPD 1
/
Almathera Ten on Ten - Disc 2: CDPD 1.iso
/
pd
/
301-325
/
309
/
bind
/
bind.doc
< prev
next >
Wrap
Text File
|
1995-03-14
|
10KB
|
301 lines
Bind - Binding (glue) library builder
Version 1.2 - 31-Dec-89
Overview
--------
This program takes a standard .fd (function definition) file and
generates a binding library for the functions defined in the .fd file.
The bindings are generated based on a set of rules for a target compiler
defined in a file called "bindfile". These rules specifiy which
registers need to be preserved, how the arguments are passed on the
stack, and the syntax to call an assembler and a librarian.
Unlike similar programs, Bind actually generates a linkable library instead
of just a bunch of assembly files and a makefile. It does this by running
an assembler and librarian specified for a given set of rules in the
bindfile.
Requirements
------------
Bind requires arp.library v39+ (release 3) to function.
New stuff
---------
Version 1.2 - 10-Dec-89
Now can function for libraries that don't have a fixed Base pointer
(like cia.resource) (no ##base line). In such cases, it assumed
that A6 is passed to the glue function as one of the arguments.
Also now uses _LVO symbols instead of negative numbers in assembly
glue modules. This should make the assembly output more useful.
Version 1.1 - 9-Jul-89
This version of Bind was more or less made necessary because v1.0
choked on the iffparse_lib.fd function arguments. Bind now correctly
deals with register argument lists and is much more bullet-proof than
it previously was.
The zlib program has been removed for this version since the ARP Join
command can be used instead. Since Bind requires ARP, you should have
already have the ARP Join command.
Arc File Contents
-----------------
Bind -- The Bind program
Bind.doc -- This file
bindfile -- A sample bindfile containing rules for Aztec C (small
code/data and large code/data version) and Lattice C.
The Lattice C rules should work for any language that
uses the amiga.lib supplied by C=.
misc_res.fd -- An .FD file for the Amiga's misc.resource. According
to the the RKM manuals, this resource is supposed to be
called only from assembly. I can see no good reason for
this other than that no one ever made any glue routines
for it. Now you can make your own using Bind.
Usage
-----
The syntax for Bind is:
Bind [opts] <.fd file>
<.fd file> - name of the function definition file to use as a
source. The ".fd" portion may be left off of the name.
The output library name is derived from the portion of
the .fd file to the left of the period (e.g.
midi_lib.fd will generate midi_lib.lib)
opts:
-a generate assembly only
-c generate object modules only
-f<s> specify alternate bindfile
-o<s> specify output library name
-r<s> specify rule name
-w<s> specify work directory (default=CCTEMP env. variable)
A library is built by first generating an object module for each binding
routine and an LVO definition module. Each module is created by writing
an assembly file to the work directory and then assembling it. Once all
the object modules are generated they are collected into a library.
Temporary files (assembly and object) are deleted from the work
directory as soon as they are no longer needed. The actual invocations
for the assembler and librarian depend on the selected set of rules.
Binding rules are defined in a "bindfile". By default this file is
called bindfile and resides in the current directory or the s:
directory. An alternate bindfile may be specified with the -f switch.
A bindfile contains entries for target compilers. Each entry contains
rule definitions that specify how to build a binding routine for the
target compiler. The syntax is as follows:
<target>:
<rule key> = <value>
.
.
.
<rule key> = <value>
<target>:
<rule key> = <value>
.
.
.
<rule key> = <value>
.
.
.
The target name can contain any name but must not contain embedded
spaces. It should begin in the first column and be terminated with a
colon. Target name matching is case insensitive.
Rule keys must be preceded with white space and spelled exactly as
follows (case is not significant). They may be placed in any order
within a rule set.
Comment = <comment>
An optional comment string to be placed in assembly files (only
visible if the -a switch is used) and the file comment for the
output library (visible with the List command). The default is the
rule name.
StackOffset = <offset>
Specifies how many bytes preceded arguments in the stack frame when
the routine first becomes active. If nothing is pushed on the
stack between the arguments and the return location (pushed by jsr)
then <offset> would be 4. This depends very heavily on how the
target compiler calls routines. The default value is 4.
SaveRegs = <register set>
This specifies the registers that the compiler expects to have
preserved. Use a standard 68000 MOVEM register set here (e.g.
d2-d7/a2-a5). The default is to preserve d2-d7/a2-a6. Currently
you are not allowed to preserve D0 or A7 this way. D0 is where
return values from placed by standard Kernal routines. A7 is the
stack pointer and is automatically preserved.
Assembler = <asm syntax>
Specifies the name of the assembler to use and its syntax. Two
string substitutions are performed here.
$A - gets replaced by the name of the assembly file
generated by Bind.
$O - gets replaced by the name of the object module that
should be produced by the assembler.
(e.g. as $A -o $O) Bind generates assembly files suffixed with
.asm and expects object files to suffixed by .o. These suffixes
are supplied with the $a and $o string substitutions.
The assembler used should be capable of generating a
non-zero return code on failure in order to shut down Bind.
Both Aztec's as and MCC's assem behave well.
The assembler is loaded using the ARP SyncRun() function so that
the current path will be searched in order to find the assembler.
The default is no assembler. This will not permit you to make
anything other than assembly files.
Librarian = <lb syntax>
Specifies the name of the librarian to use and its syntax. Two
string substitutions are performed here.
$L - is replaced by the selected name of the output library.
$O - is replaced by the entire list of object modules to
place in the library.
(e.g. lb $L $O) By default Bind will generate a library name based
on the .fd file name (e.g. midi_lib.fd becomes midi_lib.lib). You
can select another output library name using the -o option.
As with the assembler, the librarian should be capable of
generating a non-zero return code on failure in order. Aztec's lb
utility, and the ARP Join command all behave this way.
To generate an Amiga object module library (ALink/BLink
compatible), use the ARP Join command as the Librarian:
Librarian = join $O as $L
Amiga object module libraries appear to be simply a concatenation
of the constituent object modules so Join can be used to make one
out of object files. NOTE: The AmigaDOS Join command can't be used
for this since it is limited to joining no more than 15 files.
The default is no librarian. This will prevent you from
going beyond the object module stage.
Comments may be placed in the bindfile if they are preceeded with a
pound sign (#) in the first column (like makefile comments). Also,
blank lines are considered comments.
There is a sample bindfile contained in the .arc file containing rules for
Aztec C and Lattice C. The Lattice C rules may be applicable to other
languages as well since they conform to the Amiga register preservation
rules.
Work files
----------
Work files are placed in the "work directory". The work directory is
determined in one of two ways. If none is specified, the directory
associated with the environment variable CCTEMP is used (this is set by
either the Manx or ARP Set command or the C= or ARP SetEnv command). You
may override this by using the -w switch to specify any directory. The
default is the current directory.
Work files are automatically deleted when they are no longer needed or
when the program fails or is aborted using Control-C.
The options
-----------
-a Causes Bind to stop after generating the assembly code for the
bindings. They appear in the work directory.
-c Causes Bind to assemble the modules that it generates but leave just
the object modules without making a library.
-f Allows you to specify some other file to use as a bindfile. The
default bindfile may exist in the current directory or in the s:
directory.
-o Allows you to specify another name for the output library. The default
is made by replacing .fd in the source file name with .lib. The
library name you specify here will be suffixed with .lib unless you
specify some other suffix.
A file comment is set for the output library indicating which rules
were used to create it. The Comment bindfile rule is used for the file
comment if present, otherwise the rule name is used.
-r Specifies a rule name. The default is to use the first rule in the
bindfile.
-w Specifies an alternate work directory. The default is the value of the
CCTEMP environment variable (set by Set or SetEnv).
Tech info
---------
The program was compiled using Aztec C3.6a. Everything described works. At
the very least this can be used to generate bindings for Aztec C (any
model) and Lattice C.
Compilers that don't use A7 for a stack, don't return values in D0, pack
the arguments in reverse order, or require that the bindings pop arguments
off the stack are not currently supported by Bind. This may change if
there is demand for this and the appropriate technical data is available.
.fd files are not described in this document.
Last words
----------
Bind is copyright (c) 1987-89 by Pregnant Badger Software, but feel free to
distribute it for non-profit.
Bill Barton
Bix: peabody
plink: peabody